package StudyCode.summary.mycollection;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ConvertArrayAsSet {
	@SafeVarargs
	public static <E> Set<E> asSet(E... elements) {
		if (elements == null || elements.length == 0) {
			return Collections.emptySet();
		}
		LinkedHashSet<E> set = new LinkedHashSet<E>(
				elements.length * 4 / 3 + 1);
		Collections.addAll(set, elements);
		return set;
	}
}
